//=============================================================================

#ifndef ASYSTEM_H
  #define ASYSTEM_H

//=============================================================================

#include "doWorld.h"
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include "doCommon.h"
#include "doLog.h"
#include "aProfile.h"
#include "aCamera.h"

//=============================================================================

#define SYS aSystem::asGetInstance()

//=============================================================================

enum asmRet
{
  SR_WELL = -128,
  SR_NULLED_PATH_TO_PROFILES_FOLDER,
};

//=============================================================================

class aSystem
{
  private:
    aSystem();
    ~aSystem();

  public:
    inline static aSystem& asGetInstance()    {static aSystem sys; return sys;}
    inline GLsizei asGetWidth()const          {return width;}
    inline GLsizei asGetHeight()const         {return height;}
    inline void asCheckCamera()               {eyes.acUpdateCamera(SYS.asGetWidth()/2, SYS.asGetHeight()/2);}
    inline int asGetFPS()const                {return fps;}

    bool asOpenGLInit();
    void asResizeOpenGL(GLsizei w, GLsizei h);
    void asPaintTheWorld();
    void asSetDisplayToFullscreen();
    void asPrintLastError()const; //if some windows error appears - call me then =)
    void asKeyDown(WPARAM wp);
    void asCalculateFPS();
    void asParseParameters(const aString& str);
    void asGetLineUnderMouse(aVector& n, aVector& f);

  public:
    HGLRC glRc;
    HDC hDc;
    HWND hWnd;

  private:
    int fps;
    aProfile useProfile;
    GLsizei width, height;
    GLdouble fov;
    GLdouble aspect;
    GLdouble nearClip;
    GLdouble farClip;
    GLbitfield clearField;
    aCamera eyes;
    float framesInterval;
    float motionSpeed;
    
    // for debug only
    const float debug_cameraSpeed;
};

//=============================================================================

#endif

//=============================================================================
